import dayjs from "dayjs";
import {h} from 'vue';
import {ElSwitch} from "element-plus";

export default {
    switch(field, row, column, options) {
        return h(
            ElSwitch,
            {
                'modelValue': row[field.prop],
                'active-icon': 'Check',
                'inactive-icon': 'Close',
                'inline-prompt': true,
                'readonly': true,
            }
        )
    },
    translate(field, row, column, options) {
        let result = options[field.prop].filter(item => {
            return row[field.prop] === item[field.storeValue || 'value']
        });
        return result[0][field.showValue || 'label'];
    },
    datetimerange(field, row, column, value, options) {
        return `${dayjs(row[field.prop][0]).format('YYYY-MM-DD HH:mm:ss')} - ${dayjs(row[field.prop][1]).format('YYYY-MM-DD HH:mm:ss')}`;
    },
}
